﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace Woodlands
{
    public class Module
    {

        private string moduleName, moduleCode, moduleID, courseID_fk2, moduleLevel, modulePoints, ass1, ass2, status;

        public Module()
        {
            moduleID = "";
            courseID_fk2 = "";
            moduleName = "";
            moduleCode = "";
            moduleLevel = "";
            ass1 = "";
            ass2 = "";
            status = "";
        }
        public Module(string moduleIDin, string nameIn, string moduleCodeIn, string courseIDin, string moduleLevelIn, string modulePointsIn,
                      string assessmentOneWeightingIn, string assessmentTwoWeightingIn, string statusIn)
        {
            moduleID = moduleIDin;
            moduleName = nameIn;
            moduleCode = moduleCodeIn;
            courseID_fk2 = courseIDin;
            moduleLevel = moduleLevelIn;
            modulePoints = modulePointsIn;
            ass1 = assessmentOneWeightingIn;
            ass2 = assessmentTwoWeightingIn;
            status = statusIn;
        }

        public static async Task<DataTable> search(string by, string searchTerm)
        {
            return await Database.searchModule(by, searchTerm);
        }

        public static async Task achive(string code, string id)
        {
            await Database.achiveModule(code, id);
            return;
        }

        public static async Task<Module> getModule(string code, string id)
        {
            return await Database.getModule(code, id);
        }

        public async Task amend()
        {
            await Database.amendModule(this);
            return;
        }

        public async Task create()
        {
            await Database.createModule(this);
            return;
        }

        public static string nextID(string x)
        {
            return Database.nextModuleID(x);
        }

        public string AssessmentTwoWeighting
        {
            get { return ass2; }
            set { ass2 = value; }
        }

        public string AssessmentOneWeighting
        {
            get { return ass1; }
            set { ass1 = value; }
        }

        public string ModulePoints
        {
            get { return modulePoints; }
            set { modulePoints = value; }
        }

        public string ModuleLevel
        {
            get { return moduleLevel; }
            set { moduleLevel = value; }
        }

        public string ModuleCode
        {
            get { return moduleCode; }
            set { moduleCode = value; }
        }

        public string CourseID
        {
            get { return courseID_fk2; }
            set { courseID_fk2 = value; }
        }

        public string ModuleID
        {
            get { return moduleID; }
            set { moduleID = value; }
        }

        public string Name
        {
            get { return moduleName; }
            set { moduleName = value; }
        }

        public string Status
        {
            get { return status; }
            set { status = value; }
        }
    }
}
